package cn.zhf.shop.controller;

import cn.zhf.shop.entity.AgentAudit;
import cn.zhf.shop.entity.Message;
import cn.zhf.shop.service.AgentAuditService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;

@RestController
@RequestMapping("/api/AgentAudit")
@Api(tags = "代理人操作审核管理")
public class AgentAuditController {
    @Resource
    private AgentAuditService agentAuditService;

    @ApiOperation(value = "根据审核id查看审核记录")
    @GetMapping("/id")
    public Message selectById(int id){
        return agentAuditService.selectByPrimaryKey(id);
    }

    @ApiOperation(value = "查看所有审核记录")
    @GetMapping("/all")
    public Message selectAll(){
        return agentAuditService.selectAll();
    }

    @ApiOperation(value = "查看所有审核记录(不显示未提交)")
    @GetMapping("/allNoZero")
    public Message selectAllNoZero(){
        return agentAuditService.selectALLNoZero();
    }

    @ApiOperation(value = "增加代理人审核记录")
    @PostMapping("/")
    public Message insert(AgentAudit agentAudit){
        agentAudit.setPostTime(new Date());
        return agentAuditService.insertSelective(agentAudit);
    }

    @ApiOperation(value = "根据id删除审核记录")
    @DeleteMapping("/")
    public Message delete(int id){
        return agentAuditService.deleteByPrimaryKey(id);
    }

    @ApiOperation(value = "修改审核记录")
    @PutMapping("/id")
    public Message update(AgentAudit agentAudit){
        return agentAuditService.updateByPrimaryKeySelective(agentAudit);
    }

    @ApiOperation(value = "修改审核状态")
    @PutMapping("/updateStatus")
    public Message updateStatus(int agentAuditUserId,int agentAuditId,int Auditstatus,String rejectionReason){
        return agentAuditService.updateStatus(agentAuditUserId,agentAuditId,Auditstatus,rejectionReason);
    }
    @ApiOperation(value = "根据记录id修改上传状态")
    @PutMapping("/updateAuditPostStatusByAgentAuditId")
    public Message updateAuditPostStatusByAgentAuditId(Integer updatedAuditPostStatus, Integer agentAuditId){
        return agentAuditService.updateAuditPostStatusByAgentAuditId(updatedAuditPostStatus, agentAuditId);
    }

    @ApiOperation(value = "根据postUserId模糊搜索")
    @GetMapping("/mohuSearch/postUserId")
    public Message mohuSearchByPostUserId(String str,Integer postUserId){
        return agentAuditService.mohuSearchByPostUserId(str,postUserId);
    }

    @ApiOperation(value = "审核模糊搜索")
    @GetMapping("/mohuSearch")
    public Message mohuSearch(String str){
        return agentAuditService.mohuSearch(str);
    }

    @ApiOperation(value = "根据上报者id和上报状态获取记录")
    @GetMapping("/selectByPostUserIdAndAuditPostStatus")
    public Message selectByPostUserIdAndAuditPostStatus(Integer postUserId, Integer auditPostStatus){
        return agentAuditService.selectByPostUserIdAndAuditPostStatus(postUserId, auditPostStatus);
    }

    @ApiOperation(value = "根据上报者id获取记录")
    @GetMapping("/selectByPostUserId")
    public Message selectByPostUserId(Integer postUserId){
        return agentAuditService.selectByPostUserId(postUserId);
    }


}
